<template>
  <div class="logo" style="display:flex;align-items: center;">
    <router-link :to="{name:'Console'}">
      <div style="display:flex;align-items:center;">
        <img src="@/assets/logo.jpg" style="height:20px;width:auto;" />
        <h1 v-if="showTitle">{{ this.titles }}</h1>
      </div>
    </router-link>
  </div>
</template>

<script>
import { mixin, mixinDevice } from '@/utils/mixin'

export default {
  name: 'Logo',
  mixins: [mixin, mixinDevice],
  data () {
    return {
      titles: ''
    }
  },
  props: {
    title: {
      type: String,
      default: '我的开发模板',
      required: false
    },
    showTitle: {
      type: Boolean,
      default: true,
      required: false
    }
  },
  created () {
    if (this.layoutMode === 'topmenu') {
      if (this.title.length > 8) {
        this.titles = this.title.substring(0, 8) + '...'
      } else {
        this.titles = this.title
      }
    } else {
      if (this.title.length > 10) {
        this.titles = this.title.substring(0, 8) + '...'
      } else {
        this.titles = this.title
      }
    }
  }
}
</script>
